﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Utils;
using Settings;

namespace PanasonicWarranty.DAL
{
    public partial class DBSysMenu
    {
        public static SqlDataReader GetByUser(int userID)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SysMenu_GetByUser", userID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static SqlDataReader GetByLink(string link)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SysMenu_GetByTop", "", string.Format("Link = '{0}'", link), "");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// Lấy danh sách menu để phân quyền theo nhóm người dùng.
        /// </summary>
        /// <param name="GroupID"></param>
        /// <returns></returns>
        public static SqlDataReader GetAllToSetRights(int GroupID)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SysMenu_GetBySysGroupID", GroupID);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
    }
}
